<template>
  <node
    title="发起人"
    :is-root="true"
    :content="content"
    @selected="selected"
    @insertNode="insertNode"
    placeholder="所有人"
    header-bgc="#7a939d"
    header-icon="ele-UserFilled"
  />
</template>

<script>
import Node from './Node.vue'
import { computed, toRefs } from 'vue'
export default {
    name: 'RootNode',
    components: { Node },
    props: {
        config: {
        type: Object,
            default: () => {
                return {}
            },
        },
    },
    emits: ['selected', 'insertNode'],
    setup(props, context) {
        const { config } = toRefs(props)
        const selected = () => {
            context.emit('selected')
        }
        const insertNode = (type) => {
            context.emit('insertNode', type)
        }
        const content = computed(() => {
            if (config.value.props.assignedUser.length > 0) {
                let texts = []
                config.value.props.assignedUser.forEach((org) => texts.push(org.name))
                return String(texts).replaceAll(',', '、')
            } else {
                return '所有人'
            }
        })
        return {
            selected,
            insertNode,
            content
        }
    }
}
</script>

<style>

</style>